﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Remote_Desktop_Administrator
{
    public partial class CryptKeyForm : Form
    {
        public CryptKeyForm()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            MessageBox.Show("No encryption/decryption used.");
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (radYes.Checked)
            {
                if (txtKey.Text != "")
                {
                    Encryption.FixSecretKey(txtKey.Text);
                    Connection.blnEncrypt = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Key used for encryption/decryption cannot be blank.");
                }
            }
            else
            {
                //MessageBox.Show("No encryption/decryption used.");
                this.Close();
            }
        }

        private void radYes_CheckedChanged(object sender, EventArgs e)
        {
            txtKey.ReadOnly = false;
            chkShowKey.Enabled = true;
        }

        private void CryptKeyForm_Load(object sender, EventArgs e)
        {
            Connection.blnEncrypt = false;
            txtKey.ReadOnly = true;
            chkShowKey.Enabled = false;
        }

        private void radNo_CheckedChanged(object sender, EventArgs e)
        {
            txtKey.ReadOnly = true;
            chkShowKey.Enabled = false;
        }

        private void chkShowKey_CheckedChanged(object sender, EventArgs e)
        {
            if (chkShowKey.Checked)
            {
                txtKey.PasswordChar = '\0';
            }
            if (!chkShowKey.Checked)
            {
                txtKey.PasswordChar = '*';
            }
        }
    }
}
